<?php
$this->breadcrumbs=array(
	'Bills'=>array('index'),
	'Manage',
);

$this->menu=array(
	array('label'=>'List Bills', 'url'=>array('index')),
	array('label'=>'Create Bills', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('bills-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Bills</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->

<?php
	/*$filterbillsbydate = Yii::app()->session->get("filterbillsbydate",false);
	
	echo CHtml::tag("br");
	echo CHtml::checkBox("filterbydate",$filterbillsbydate,array('id'=>"filterbillsbydate"));
	Yii::app()->clientScript->registerScript('filterclick',"
		$('#filterbillsbydate').click(function() {
		  var ajaxUrl = '/index.php?r=site/session&key=filterbillsbydate&value='+this.checked;
		  jQuery.ajax({'url':ajaxUrl,'cache':false});
		});
	");*/
	//echo "Фільтрувати за датою: ";
	//$this->renderPartial("/products/period",array("startdate"=>$startdate,"enddate"=>$enddate));
	
	$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'bills-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'id',
		'name',
		array(
			'value'=>'$data->supplier->name',
			'header'=>'Постачальник',
			'name'=>'supplierid',
			'filter'=>CHtml::dropDownList("Bills[supplierid]",$model->supplierid,$dataForSuppliersDropdown)
		),
		array(
			'value'=>'$data->getPaidSum()',
			'header'=>'Заплачено',
			'name'=>'paidsum',
		),
		'timeline',
		'created',
		array(
			'value'=>'Bills::getPaidStatusText($data->paid)',
			'header'=>'Оплачено',
			'name'=>'paid',
			'filter'=>CHtml::dropDownList("Bills[paid]",$model->paid,array("-1"=>Bills::getPaidStatusText(),"0"=>Bills::getPaidStatusText(0),"1"=>Bills::getPaidStatusText(1)))
		),
		/*
		'description',
		'paid',
		*/
		array(
			'class'=>'CButtonColumn',
		),
	),
)); ?>
